<template>
  <div class="container">
    <el-input
    v-model="notice.content"
    style="width: 400px;margin-bottom: 100px;"
    :rows="6"
    type="textarea"
    placeholder="请输入公告"
  />
  <el-button type="primary" @click="changeNotice">保存</el-button>
  </div>
</template>

<script lang="ts" setup>
import {ref,reactive,onBeforeMount} from 'vue'
import {getnotice,changenotice} from '@/service/api/notice'
import { ElMessage } from 'element-plus';
onBeforeMount(()=>{
  getNotice()
})

let notice=ref({})
function getNotice(){
  getnotice().then((res)=>{
    if(res.data.code===200){
      notice.value=res.data.data
      console.log(notice.value)
    }
  })
}

function changeNotice(){
  changenotice({notice_id:notice.value.notice_id,content:notice.value.content}).then(res=>{
    if(res.data.code===200){
      ElMessage({
    message: "保存成功",
    type: "success",
  });
    }
  })
}
</script>


<style lang="scss" scoped>
.container{
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
</style>
